#ifndef ATTRIBUTEMODEL_H
#define ATTRIBUTEMODEL_H

#include <QStringListModel>
#include "Node.h"

class AttributeModel : public QStringListModel
{
	Q_OBJECT
private:
	Node* currentNode;
	QVector<QString> key;
public:
	AttributeModel();
	~AttributeModel();

	QVariant data(const QModelIndex &index, int role) const;
	Qt::ItemFlags flags(const QModelIndex &index) const;
	QVariant headerData(int section, Qt::Orientation orientation,
			int role = Qt::DisplayRole) const;
	QModelIndex index(int row, int column,
			const QModelIndex &parent = QModelIndex()) const;
	QModelIndex parent(const QModelIndex &index) const;
	int rowCount(const QModelIndex &parent = QModelIndex()) const;
	int columnCount(const QModelIndex &parent = QModelIndex()) const;

	bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole);

	void selectNode(Node* node);
	void setNodeAttr(Node* node, const QString& key, const QVariant& val);
	void removeNodeAttr(Node* node, const QString& key);
	void moveNodeAttr(Node* node, const QString& key, const QString& newKey);
	void removeNodeAttrByIndex(Node* node, int idx);
	void restoreNodeAttrByIndex(Node* node, int idx, const QString& key, const QVariant& val);

private slots:
	void removeAttribute();
};
#endif